<template>
    <div class="search-list" v-show="searches.length">
        <transition-group name="list" tag="ul">
            <li class="search-item"  v-for="(item,index) in searches" :key="index" @click="selectSearch(item)">
                <span class="text">{{item}}</span>
                <span class="icon" @click.stop="deleteHistory(item)">
                    <i class="iconfont icon-closesepwindow"></i>
                </span>
            </li>
        </transition-group>
    </div>
</template>
<script>
export default {
    props:{
        searches:{
            type:Array,
            default:()=>{}
        }
    },
    methods:{
        //选中搜索
        selectSearch(item){
            this.$emit("select",item)
        },
        // 删除历史记录中的一项
        deleteHistory(item){
             this.$emit("delete",item)
        }

    }
}
</script>
<style lang="stylus">
 @import "../../common/stylus/variable"

  .search-list
    .search-item
      display: flex
      align-items: center
      height: 40px
      overflow: hidden
      &.list-enter-active, &.list-leave-active
        transition: all 0.1s
      &.list-enter, &.list-leave-to
        height: 0
      .text
        flex: 1
        color: $color-text-l
      .icon
        extend-click()
        .icon-delete
          font-size: $font-size-small
          color: $color-text-d
</style>
